using System;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using MvcMall.Core.Domains;

namespace MvcMall.Data.NHibernateMaps
{
    public class AdminRoleMap : IAutoMappingOverride<AdminRole>
    {
        public void Override(AutoMapping<AdminRole> mapping)
        {
            mapping.HasManyToMany(m => m.AdminPowers)
                .ParentKeyColumn("AdminRoleId")
                .ChildKeyColumn("AdminPowerId")
                .Table("AdminRolePowers");

            mapping.HasManyToMany(m => m.AdminMenus)
                .ParentKeyColumn("AdminRoleId")
                .ChildKeyColumn("AdminMenuId")
                .Table("AdminRoleMenus");
        }
    }
}